import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: [
      { find: '@', replacement: '/src' }, // 或者使用path.resolve确保跨平台兼容性
    ],
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    AutoImport({
      include: [
        /\.vue$/,
        /\.vue\?vue/, // .vue
      ],
      imports: [
        'vue',
      ],
    }),
  ],
  server: {
    host: '0.0.0.0',
    proxy: {
      "/dataset": {
        target: "http://127.0.0.1:6111",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dataset/, ""),
      }
    },
  },
  base: './'
})
